﻿using System;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LTJ.Common;
using LTJ.FrameWork;
using LTJ.Entity;
using LTJ.Common.Generic;
using System.Data;

namespace uswinweb.datacontrol
{
    public partial class search_list : System.Web.UI.UserControl
    {
        public List<RouteBaseInfo> routesTab = new List<RouteBaseInfo>();
        public string strWhere = "";
        public int pagesize = 10;
        public int pageindex = SASRequest.GetInt("currentPage", 1);
        public string action = SASRequest.GetString("action");
        public string parpms = SASRequest.GetString("parms").Trim();
        public string pageList = "";
        public string orderstr = "";
        public int gid = 0;
        public int cid = SASRequest.GetInt("cid", 0);
        public int recordcount = 0;
        public string qyg = SASRequest.GetString("qyg");
        public string mdg = SASRequest.GetString("mdg");
        public string cs = SASRequest.GetString("cs");
        public string hx = SASRequest.GetString("hx");
        public string minoPageStr = "";        

        public search_list()
        {
            if (pageindex < 0) pageindex = 1;

            if (Utils.StrToInt(FrameWorkUtil.GetCookie("userid"), -1) > 0)
            {
                gid = TypeConverter.ObjectToInt(Users.GetUser(Utils.StrToInt(FrameWorkUtil.GetCookie("userid"), -1)).gid, 0);
            }

            strWhere = RouteBases.GetRouteBaseCondation(cid, 1, qyg, mdg, hx, cs);
            recordcount = RouteBases.GetRouteBasesCount(strWhere);
            routesTab = RouteBases.GetRouteBaseListByPage(pageindex, pagesize, strWhere, orderstr);
            pageList = GetPageList(recordcount, pagesize, pageindex);
            minoPageStr = LTJ.Common.Utils.LuffyPage2(recordcount, pagesize, pageindex, "search_list.ascx", "qyg=" + qyg + "&mdg=" + mdg + "&cs=" + cs + "&hx=" + hx + "&cid=" + cid + "&action=" + action + "&parms=" + parpms + "", "showdata");
        }

        public string GetPageList(int recordcount, int pagesize, int currentpage)
        {
            if (SASRequest.GetInt("postnumber", 0) > 0)
            {
                return LTJ.Common.Utils.LuffyPage(recordcount, pagesize, currentpage, "search_list.ascx", "postnumber=" + SASRequest.GetInt("postnumber", 0), "showdata");
            }
            else
            {
                return LTJ.Common.Utils.LuffyPage(recordcount, pagesize, currentpage, "search_list.ascx", "qyg=" + qyg + "&mdg=" + mdg + "&cs=" + cs + "&hx=" + hx + "&cid=" + cid + "&action=" + action + "&parms=" + parpms + "", "showdata");
            }
        }
        public string GetName(string pcode, string type)
        {
            string msg = "&nbsp;";
            string strWhere = " code='" + type.Trim() + "' and tcode='" + pcode.Trim() + "' ";
            BaseDataInfo binfo = BaseDatas.GetBaseDataByStr(strWhere);
            if (binfo != null)
            {
                msg = binfo.name;
            }
            return msg;
        }
        public string GetMsgStr(string code)
        {
            DataTable bdInfo = new DataTable();
            string msg = "";
            bdInfo = BaseDatas.GetDestportsMsg(" a.code='ports' and a.tcode='" + code + "'");
            if (bdInfo.Rows.Count != 0)
            {
                msg += "所属航线：" + bdInfo.Rows[0]["sshx"].ToString() + "<br/>";
                msg += "所属国家：" + bdInfo.Rows[0]["ssgj"].ToString() + "<br/>";
                msg += "中文名：" + bdInfo.Rows[0]["name"].ToString() + "<br/>";
                msg += "英文名：" + bdInfo.Rows[0]["ename"].ToString() + "<br/>";
            }
            return msg;
        }

    }
}